package com.yuchting.dinneronline.client.common;

import com.google.gwt.json.client.JSONObject;


public class Config {
		
	private int m_sheetTimeStart = (9 << 16) | 30;
	
	private int m_sheetTimeEnd = (10 << 16) | 30;
	
	private String m_prompt = "这是提示";
	
	public int getStartHour(){return m_sheetTimeStart >>> 16;}
	public int getStartMinutes(){return m_sheetTimeStart & 0x0000ffff;}
	
	public int getEndHour(){return m_sheetTimeEnd >>> 16;}
	public int getEndMinutes(){return m_sheetTimeEnd & 0x0000ffff;}
	
	public String getPrompt(){	return m_prompt;}
	public void setPrompt(String _prompt){m_prompt = _prompt;}
	
	public void setStartTime(int _hour,int _minutes){
		m_sheetTimeStart = (_hour << 16) | _minutes;
	}
	
	public void setEndTime(int _hour,int _minutes){
		m_sheetTimeEnd = (_hour << 16) | _minutes;
	}
	
	public JSONObject toJSON(){
		
		YuchJSONObject t_result = new YuchJSONObject();
		try{
			t_result.put("start",m_sheetTimeStart);
			t_result.put("end",m_sheetTimeEnd);
			t_result.put("prompt",m_prompt);
		}catch(Exception e){
			System.err.println("Config toJSON Error:");
			e.printStackTrace(System.err);
		}
		
		return t_result.m_json;
	}
	
	public void fromJSON(YuchJSONObject _json){
		
		try{
			m_sheetTimeStart = _json.getInt("start");
			m_sheetTimeEnd 	 = _json.getInt("end");
			m_prompt		 = _json.getString("prompt");
			
		}catch(Exception e){
			System.err.println("Config fromJSON Error:");
			e.printStackTrace(System.err);
		}
	}
	
}
